#cmake file for test refer to jpegwrapper 
#author:guyadong
#created:2018/04/25
cmake_minimum_required( VERSION 3.0...3.15 )
project( testjpegwrapper LANGUAGES CXX)
#判断编译类型和版本是否满足编译要求
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_11 _cxx11_enable)
if(NOT _cxx11_enable)
	message(FATAL_ERROR "Compiler not supported C++ 11 standard")
endif()
unset(_cxx11_enable)
find_package(jpegwrapper REQUIRED)
find_package(cimg QUIET REQUIRED)
find_package(X11)
# 定义所有的源文件列表  
set(_CPP_SOURCE_FILES
    testCImg.cpp 
    )
add_executable(test_jpegwrapper ${_CPP_SOURCE_FILES})
target_link_libraries(test_jpegwrapper jpegwrapper::jpegwrapper cimg::cimg $<TARGET_NAME_IF_EXISTS:X11::X11>)
target_compile_options(test_jpegwrapper PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/wd4819> $<$<CXX_COMPILER_ID:GNU>:-std=c++11>)
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) 
	# 复制测试图像到${PROJECT_BINARY_DIR}
	file(RELATIVE_PATH _current_folder ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR})
	file(COPY ${CMAKE_CURRENT_LIST_DIR}/images DESTINATION ${PROJECT_BINARY_DIR}/${_current_folder})
	message(STATUS "copy ${CMAKE_CURRENT_LIST_DIR}/images to ${PROJECT_BINARY_DIR}/${_current_folder}")
	unset(_current_folder)
endif()


# Cleanup temporary variables.
unset(_CPP_SOURCE_FILES)
